import React, { Component } from 'react'
import PropTypes from 'prop-types'
import './index.css'
import Item from '../Item'

export default class List extends Component {

  static propTypes = {
    todos: PropTypes.array.isRequired,
    changeStatus: PropTypes.func.isRequired,
    deleteTodo: PropTypes.func.isRequired
  }

  render() {
    const { todos, deleteTodo, changeStatus } = this.props
    return (
      <div className="list">
        <ul>
          {
            todos.map(todo => {
              return <Item key={todo.id} {...todo} onChangeStatus={changeStatus} handleDelete={deleteTodo} />
            })
          }
        </ul>
      </div>
    )
  }
}
